package design.structural.flyweight;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zxs
 * @since 2020/05/25
 */
public class FlyweightFactory {

    private static final ConcurrentHashMap<String,Flyweight> map = new ConcurrentHashMap<>();

    public static Flyweight getFlyweight(String name){
        return map.computeIfAbsent(name,(key) -> new ConcreteFlyweight());
    }
}
